package cn.lxg.service;

import cn.lxg.dao.TaoLunDao;
import cn.lxg.pojo.TTaoLunContent;
import cn.lxg.pojo.TTaoLunTitle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TaoLunServiceImpl {

    @Autowired
    TaoLunDao taoLunDao;


    public String addTaoLun(TTaoLunTitle lunTitle) {
        int rows = taoLunDao.addTaoLun(lunTitle);
        if (rows == 1) {
            return "创建成功！";
        }
        return "创建失败！";
    }

    public List<TTaoLunTitle> getTitleList() {
        return taoLunDao.getTitleList();
    }

    public List<TTaoLunContent> getContentList(TTaoLunContent content) {
        return taoLunDao.getContentList(content);
    }

    public int countDataLine(TTaoLunContent content) {
        return taoLunDao.countDataLine(content);
    }

    public String addTaoLun1(TTaoLunContent lunContent) {
        int rows = taoLunDao.addTaoLun1(lunContent);
        if (rows == 1) {
            return "创建成功！";
        }
        return "创建失败！";
    }

    public TTaoLunTitle getOneTitleById(Integer id) {

        return taoLunDao.getOneTitleById(id);
    }

    public String addTaoLunContent(TTaoLunContent lunContent) {
        lunContent.setCreateTime(new Date());
        int rows = taoLunDao.addTaoLun1(lunContent);
        if (rows == 1) {
            return "添加成功！";
        }
        return "创建失败！";
    }
}
